<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/8/16 15:51
 * Desc:订单创建成功添加订单日志
 */
class Listener_Order_Created_Log extends Listener_Base
{
    public function handle($args)
    {
        $self       = new self();
        $self->args = $args;
        //判断队列是否开启,如果开启则把任务推送到队列
        if ($self->queue_status) {
            //推送到队列执行
            Queue::in('default', Listener_Order_Created_Log::class, $args);
        } else {
            $self->perform();
        }
    }

    public function perform()
    {
        $order = $this->args;
        Model_Member_Order_Log::add_log($order);
        St_Log::write('订单日志', array('ordersn' => $order['ordersn']), 'event/order_created/log');
    }
}